package com.jqq.inner_;

import javafx.scene.control.Cell;

public class InnerClassExercise02 {
    public static void main(String[] args) {
        CellPhone cellPhone = new CellPhone();
        //1.传递的是实现了Bell接口的匿名内部类
        //2.重写了ring方法
        //3.相当于alarmClock的形参就是写的匿名内部类
        cellPhone.alarmClock(new Bell(){
            @Override
            public void ring() {
                System.out.println("懒猪起床了");
            }
        });
        CellPhone cellPhone2 = new CellPhone();
        cellPhone2.alarmClock(new Bell(){
            @Override
            public void ring() {
                System.out.println("小伙伴上课了");
            }
        });
    }
}

interface Bell{
    void ring();
}
class CellPhone{
    public void alarmClock(Bell bell){
        bell.ring();
    }

}